#include<stdio.h>
#include<stdlib.h>

typedef struct TREENODE
{
    int data;
    struct TREENODE* nextLeft;
    struct TREENODE* nextRight;
}treeNode;

int charsToInt(char* c)
{
    int temp=0;
    for(int i=0;i<3;i++)
    {
        if(c[i]!='\0')
        {
            temp=temp*10+c[i]-'0';
        }
    }
    return temp;
}
int* initTreeNode()
{
    char buff[255];
    int* ins=(int*) malloc(sizeof(int)*20);
    FILE* f=fopen("./Treetxt1.txt","r");
    printf("%d\n",fgets(buff,250,f));
    printf("%s\n",buff);
    printf("%c\n",buff[1]);
    char c;
    int index=0;
    int index2=0;
    int index3=0;
    char tempint[3];
    int kongge=0;
    while((c=buff[index++])!='\0')
    {
        if(c==' ')
        {
            kongge++;
            index2=0;
            if(kongge==1)
                ins[index3++]=charsToInt(tempint);
            for(int i=0;i<3;i++)
                tempint[i]='\0';
            
        }
        else{
            kongge=0;
            tempint[index2++]=c;
        }
    }
    ins[index3++]=charsToInt(tempint);
    return ins;
}

void main()
{
    int* mainIns=initTreeNode();
    printf("-------------\n");
    for(int i=0;i<20;i++)
    {
        printf("%d\t",mainIns[i]);
    }
}
